#!/usr/bin/php
<?php

require(dirname(__FILE__)."/../src_v2/classes/Token.php");


$uname   = 'admin';
$pwd_md5 = md5('admin');

$token = Token::generate($uname, $pwd_md5, 1800);

$cookie_struct = array( 'token' => $token);
$cookie_json   = json_encode( $cookie_struct );


require_once(dirname(__FILE__)."/../src_v2/classes/init.php");

$dbl = $PARAPARA->dblayer;


$email       = 'piotr.czarny@gmail.com';
$screen_name = 'pitor';
$pwd_md5     = md5( '1234');



$retval = $dbl->account_register( $screen_name, $email, $pwd_md5 );


echo "QUERY :" . $dbl->latest_query, "\n";
echo "ERROR :" . $dbl->mysql_error, "\n";
echo "ERRNO :" . $dbl->mysql_errno, "\n";

if(is_object($retval)) {
    $uid      = $retval->uid;
    $act_code = $retval->act_code;

    $retval = $PARAPARA->mail_confirmation( $email, $uid, $act_code );

    echo "Going to confirm the account now...\n";

    $retval = $dbl->account_confirm( $uid, $act_code );

    echo "    and the status for that is $retval\n";
}
else {
    echo "OMG... account not created because retval=$retval\n";
}

?>